package com.zmn.brs.common.dictionary;

import com.google.common.collect.Maps;
import com.zmn.common.dictionary.DictModel;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 类描述：字典工具类
 *
 * @author zhangyao
 * @since 2021/05/10 16:22
 */
public class Dict {

    /**
     * 描述: dictModel to Maps
     *
     * @param var VtDto list
     * @return java.util.Map<java.lang.Integer, java.lang.String>
     * @author wangjie
     * @since 16:56 2019/6/6
     **/
    public static Map<Integer, String> dictModelToMap(List<DictModel> var) {

        if (CollectionUtils.isEmpty(var)) {
            return Maps.newHashMap();
        }
        return var
                .stream()
                .collect(Collectors.toMap(DictModel::getKey, DictModel::getValue));
    }

}
